package com.niiwoo.civet.scheduler.trigger;

import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import com.alibaba.dubbo.config.annotation.Reference;
import com.alibaba.dubbo.rpc.RpcContext;
import com.niiwoo.civet.trade.service.newRefund.RefundNotifyExceptionDubboServce;

import lombok.extern.slf4j.Slf4j;

/**
 * 还款消息异常补偿任务
 *  
 * @author: kevin.jia
 * @version 1.0.0
 */
@Slf4j
@Component
public class RefundNotifyCompensationJobTrigger {

	@Reference(version = "1.0.0")
	private RefundNotifyExceptionDubboServce refundNotifyExceptionDubboServce;
	
	@Scheduled(cron = "${newRefund.scheduled-run-refundNotifyExceptionHandle}")
	public void refundNotifyExceptionHandle() {
		log.info("还款消息异常补偿 start");
		RpcContext.getContext().asyncCall(() -> refundNotifyExceptionDubboServce.compensationHandle());
	}
	
	@Scheduled(cron = "${newRefund.scheduled-run-clearHandledRecordByExceedDay}")
	public void clearHandledRecordByExceedDay() {
		log.info("还款消息定时清除已处理异常记录start");
		RpcContext.getContext().asyncCall(() -> refundNotifyExceptionDubboServce.clearHandledRecordByExceedDay(3));
	}

	@Scheduled(cron = "${newRefund.scheduled-run-sendMessageForRefund}")
	public void sendMessageForRefund() {
		log.info("sendMessageForRefund-start");
		RpcContext.getContext().asyncCall(() -> refundNotifyExceptionDubboServce.sendMessageForRefund());
	}
}